<!-- Study_FreeCourseRichtextNew.html -->
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>富文本课程</title>
       <link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<style type="text/css">
			body {
				background-color: #FFFFFF
			}
			.content_text {
				word-break: break-all;
				word-wrap: break-word;
				padding: 10px;
			}
			.content_title {
				word-break: break-all;
				word-wrap: break-word;
				text-align: center;
			}
			table {
				border: 1px solid #ccc;
				border-collapse: collapse;
				border-spacing: 0;
			}
			td, th {
				border: 1px solid #ccc;
				padding: 0;
			}
			ul li {
				list-style: disc;
			}
			ol li {
				list-style: decimal;
			}
			p {
				color: #222222;
				font-size: 14px;
			}
			.white_div {
				background-color: white;
				height: 1px;
			}
			.feeling {
				padding: 0;
				padding-top: 10px;
			}
			.feeling .title {
				margin-left: 10px;
				margin-bottom: 0;
			}
			.feeling .feeling-text-new {
				padding: 10px;
			}
			.feeling p {
				margin-bottom: 0;
			}
			img, a, button, em, del, strong, var, label, cite, small, time, mark, code, textarea, span {
				display: initial;
			}
			p,span{
				line-height: 1.2em;
			}
		</style>
	</head>
	<body>
		<div id="bewriteDIV" hidden="hidden" >
			<div class="padding10">
				<p class=" base_black_grey base_title_font">
					描述
				</p>
				<div class="base_dark_grey base_content_font according-2-rows text_indent_2" id="bewrite" onclick="openBewrite()">
					描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字
				</div>
			</div>
			<div class="div_divider"></div>
			<div style="background-color: #f0f0f0;height:5px"></div>
			<div class="div_divider"></div>
		</div>
		<div style="margin-right: 10px;margin-left: 10px;padding-top:10px;height: 200px"  class="base_none_item " id="voide" onclick="toPlayVideo()">
			<img src="../../image/img_voide.png" style="width: 100%;height: 100%;" />
		</div>
		<!--	<a href="javascript:history.go(-1)" target=_self>返回</a>-->
		<div class="content_text" id="richTextContent"></div>
		<!-- <div class="content_text" id="richTextbwrite"></div> -->
		<div class="noSign"  id="noData"  hidden="hidden">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button" class="mui-btn mui-btn-outlined" onclick="loadData()">
				重新加载
			</button>
		</div>
		<!-- <button onclick="dianwo()">点我</button> -->
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/databaseOperation.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/study_courseTimeRecord.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript">
		var other = '';
		var pageParam = '';
		DBReady = function() {
			
			bewrite();
			loadData();
		}
		function bewrite() {
			pageParam = api.pageParam;
			var bewrite = pageParam.bewrite;
			if (bewrite != "" && bewrite != null && bewrite != undefined) {
				$('#bewriteDIV').show();
				if (removeHTMLTag(bewrite).length > 0) {
					$('#bewrite').text(removeHTMLTag(bewrite));
				} else {
					$('#bewrite').text('点击查看详情');
				}
			}
		}



		function loadData() {
			var chapterid = api.pageParam.chapterid;
			var showBewrite = api.pageParam.is_dis_bewrite;
			var bewrite = api.pageParam.bewrite;
			other = api.pageParam.other;
			if (other != null && other != '') {
				var type = other.indexOf(".mp4");
				if (type > 0) {//包含mp4
					$("#voide").show();
				}
				var type1 = other.indexOf(".swf");
				if (type1 > 0) {//包含flsah课程
					$("#voide").show();
				}
				setupRichText(other);
			} else {
				$('.noSign').show();
			}
		}

		function setupRichText(other) {
			other = other.replace(/\+/g, " ");
			var newWidth = api.winWidth;
			other = other.replace("width:420;", "width='" + newWidth + "'");
			newWidth = newWidth - 10;
			other = other.replace('width="640px', "width='" + newWidth + "'px");
			other = other.replace("text-indent:28px", "text-indent:0px");
			$api.html($api.byId('richTextContent'), other);
			imageTapToSee(richTextContent);
			setupImage();
		}

		function setupImage() {
			var newWidth = api.winWidth - 20;
			$("img").each(function(i) {
				var oldWith = $(this).width();
				if (oldWith == 0) {
					setTimeout(function() {
						setupImage();
					}, 500);
					return;
				}
				if (oldWith > newWidth) {
					var oldHeight = $(this).height();
					var newHeight = oldHeight * (newWidth / oldWith);
					$(this).width(newWidth);
					$(this).height(newHeight);
				}
			});
		}

		function StrsplitVodeUrl(str) {
			var strs = str.split("http:");
			var str1 = strs[1].split(".mp4");
			return ("http:" + str1[0] + ".mp4");
		}

		function toPlayVideo() {
			var type1 = other.indexOf(".swf");
			if (type1 > 0) {//包含flsah课程
				api.toast({
					msg : "手机不支持该视频类型,请到电脑端查看",
					duration : 2000,
					location : 'bottom'
				});
				return;
			}
			var videoPlayer = api.require('videoPlayer');
			videoPlayer.play({
				path : StrsplitVodeUrl(other),
				texts : {
					head : {
						title : api.pageParam.cdetailtitle
					}
				},
				styles : {
					head : {
						backSize : 24,
						backImg : 'widget://image/vp_back.png',
						setSize : 24,
						setImg : 'widget://image/vp_more.png'
					},
					foot : {
						playSize : 24,
						playImg : 'widget://image/vp_play.png',
						pauseImg : 'widget://image/vp_pause.png',
						nextSize : 24,
						nextImg : 'widget://image/vp_next.png'
					}
				}
			}, function(ret, err) {
			});
		}

		function imageTapToSee(newsDetailsContent) {
			$('#richTextContent img').on('click', function() {
				showimg([$(this).attr("src")], 0);
			});
		}

		//描述
		function openBewrite() {
			api.openWin({useWKWebView:true,
				name : 'Student_Free_bewrite',
				url : 'Student_Free_bewrite.html',
				pageParam : {
					cdetailtitle : pageParam.cdetailtitle,
					bewrite : api.pageParam.bewrite,
					is_dis_bewrite : api.pageParam.is_dis_bewrite
				}
			});
		}
	</script>
</html>
